package com.huoyun.user.bean;

import java.util.Collection;
import java.util.Date;
import java.util.Set;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

public class User implements UserDetails {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1201690164132194616L;
	private long id;
	private String username;
	private String realname;
	private String originalPassword;
	private String password;
	private String securePassword;
	private String level;
	private String email;
	private String userImg;
	private String mobilePhone;
	private boolean checkMobilePhone;
	private boolean checkEmail;
	private boolean checkRealname;
	private boolean checkBankAccount;
	private boolean enabled;
	private String salt;
	private Date lastLoginTime;
	private Set<GrantedAuthority> authorities;
	private boolean accountNonExpired;
	private boolean accountNonLocked;
	private boolean credentialsNonExpired;
	private long credit;
	
	private String registerIp;
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getRealname() {
		return realname;
	}
	public void setRealname(String realname) {
		this.realname = realname;
	}
	public String getOriginalPassword() {
		return originalPassword;
	}
	public void setOriginalPassword(String originalPassword) {
		this.originalPassword = originalPassword;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getLevel() {
		return level;
	}
	public void setLevel(String level) {
		this.level = level;
	}
	public String getEmail() {
		return email;
	}
	public String getSecurePassword() {
		return securePassword;
	}
	public void setSecurePassword(String securePassword) {
		this.securePassword = securePassword;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getUserImg() {
		return userImg;
	}
	public void setUserImg(String userImg) {
		this.userImg = userImg;
	}
	public String getMobilePhone() {
		return mobilePhone;
	}
	public void setMobilePhone(String mobilePhone) {
		this.mobilePhone = mobilePhone;
	}
	public boolean isCheckMobilePhone() {
		return checkMobilePhone;
	}
	public void setCheckMobilePhone(boolean checkMobilePhone) {
		this.checkMobilePhone = checkMobilePhone;
	}
	public boolean isCheckEmail() {
		return checkEmail;
	}
	public void setCheckEmail(boolean checkEmail) {
		this.checkEmail = checkEmail;
	}
	public boolean isCheckRealname() {
		return checkRealname;
	}
	public void setCheckRealname(boolean checkRealname) {
		this.checkRealname = checkRealname;
	}
	public boolean isCheckBankAccount() {
		return checkBankAccount;
	}
	public void setCheckBankAccount(boolean checkBankAccount) {
		this.checkBankAccount = checkBankAccount;
	}
	public boolean isEnabled() {
		return enabled;
	}
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	public long getCredit() {
		return credit;
	}
	public void setCredit(long credit) {
		this.credit = credit;
	}
	public String getSalt() {
		return salt;
	}
	public void setSalt(String salt) {
		this.salt = salt;
	}
	public Date getLastLoginTime() {
		return lastLoginTime;
	}
	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}
	public void setAuthorities(Set<GrantedAuthority> authorities) {
		this.authorities = authorities;
	}
	public void setAccountNonExpired(boolean accountNonExpired) {
		this.accountNonExpired = accountNonExpired;
	}
	public void setAccountNonLocked(boolean accountNonLocked) {
		this.accountNonLocked = accountNonLocked;
	}
	public void setCredentialsNonExpired(boolean credentialsNonExpired) {
		this.credentialsNonExpired = credentialsNonExpired;
	}
	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return authorities;
	}
	@Override
	public boolean isAccountNonExpired() {
		return accountNonExpired;
	}
	@Override
	public boolean isAccountNonLocked() {
		return accountNonLocked;
	}
	@Override
	public boolean isCredentialsNonExpired() {
		return credentialsNonExpired;
	}
	
	public String getRegisterIp() {
		return registerIp;
	}
	public void setRegisterIp(String registerIp) {
		this.registerIp = registerIp;
	}
	public int getRateSum(){
		return 11;
	}
	public int getCompleteRate(){
		int count=0;
		if(this.username!=null)
			count+=2;
		if(this.password!=null)
			count+=1;
		if(this.realname!=null)
			count+=2;
		if(this.mobilePhone!=null)
			count+=2;
		if(this.email!=null)
			count+=2;
		if(this.userImg!=null)
			count+=2;
		return count;
	}
}
